import os
import sys

# 请在此输入您的代码
# https://www.lanqiao.cn/problems/20271/learning/?contest_id=250
n=int(input())

res=[]
for _ in range(n):
  a,b=map(int,input().split())
  res.append((a,b,a-b))

# 按照差值从大到小排序
res.sort(key=lambda x:x[2],reverse=True)

cnt1=n//2

total=0

for i in range(cnt1):
  total+=res[i][0]

for i in range(cnt1,n):
  total+=res[i][1]

print(total)